@extends('layout.default')

@section('layout.content')
  <div class="space-12"></div>

  <div class="row">
    <div class="col-xs-12">
      <form class="form-horizontal" id="staff-create" autocomplete="off">
        <div class="form-group">
          <label class="col-sm-4 control-label no-padding-right" for="name"> <b><span class="red">*</span> 名称：</b>
          </label>
          <div class="col-sm-4">
            <input type="text" class="form-control" value="{{$plan->name}}" name="name" placeholder="教学计划名称"/>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-4 control-label no-padding-right" for="desc"> 简介： </label>
          <div class="col-sm-6">
            <textarea rows="6" class="form-control" name="desc" id="desc" placeholder="简介">{{$plan->desc}}</textarea>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-4 control-label no-padding-right" for="status"></label>
          <div class="col-sm-4">
            <div class="radio">
              <label class="inline no-padding-left">
                <input name="status" type="checkbox" value="1"
                       class="ace ace-checkbox-2" {{$plan->status == 1?'checked':''}}>
                <span class="lbl"> <b>有效</b></span>
              </label>
            </div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-4 control-label no-padding-right"> </label>
          <div class="col-sm-4">
            <button type="button" class="btn btn-primary submit">
              <i class="ace-icon fa fa-check"></i>
              <span class="">确定</span>
            </button>
          </div>
        </div>

      </form>
    </div>
  </div>

@stop

@section('javascript')
  <script type="text/javascript">
      $(function () {

          $('.submit').on('click', function () {

              var uri = '{{ route('education.plan.update', array($method, $plan->id) )}}';

              $.post(uri, {
                  '_token': $("input[name='_token']").attr('value'),
                  '_method': 'put',
                  'name': $("input[name='name']").val(),
                  'status': $("input[name='status']:checked").val(),
                  'desc': $("#desc").val(),
                  'is_submit': true
              }, function (data) {
                  layer.msg(data.message, {shift: -1}, function () {
                      if (data.status === true && data.url != null) {
                          $(window).attr('location', data.url);
                      }
                  });

              }, 'json').error(function (data) {
                  layer.msg(data.responseJSON.message);
              });

          });


      });
  </script>
@stop